package org.abacus.hibernate.mandarinduck;

/**
 * @author chaoyang.li
 */
public class HibernateSessionFilter extends org.abacus.hibernate.HibernateSessionFilter implements SessionFilter {
	private static final ThreadLocal<SessionFilter> instance = new ThreadLocal<SessionFilter>();

	private HibernateSessionFilter() {
		super();
	}

	/**
	 * @author chaoyang.li
	 */
	public static SessionFilter getInstance() {
		if (instance.get() == null) {
			instance.set(new HibernateSessionFilter());
		}
		return instance.get();
	}

	/**
	 * @author chaoyang.li
	 */
	public void openIn() {
		open(HibernateSessionProvider.hibernate_cfg_in_xml);
	}

	/**
	 * @author chaoyang.li
	 */
	public void closeIn() {
		close(HibernateSessionProvider.hibernate_cfg_in_xml);
	}

	/**
	 * @author chaoyang.li
	 */
	public void openOut() {
		open(HibernateSessionProvider.hibernate_cfg_out_xml);
	}

	/**
	 * @author chaoyang.li
	 */
	public void closeOut() {
		close(HibernateSessionProvider.hibernate_cfg_out_xml);
	}
}
